home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’89 / SpiNit / SpiNit.a < prev    next >
Encoding:
Text File  |  1989-06-16  |  1.9 KB  |  98 lines  |  [TEXT/MPS ]

  1. ;
  2. ;                    SpINIT      I N I T
  3. ;
  4. ;    Patch show window to spin & zoom on ShowWindow
  5. ;
  6.  
  7.  
  8.     IMPORT    SpinFrame
  9.  
  10.  
  11.     PRINT            OFF
  12.         INCLUDE 'QuickEqu.a'
  13.         INCLUDE 'ScriptEqu.a'
  14.         INCLUDE 'ToolEqu.a'
  15.         INCLUDE 'SysEqu.a'
  16.         INCLUDE 'Traps.a'
  17.         INCLUDE 'PackMacs.a'
  18.     PRINT            ON
  19.  
  20.  
  21. Pack3trap    EQU    $1EA                    ; trap num for Pack 3 ($A9EA)
  22. ShowWind    EQU    $115                    ; trap num for Pack 3 ($A915)
  23. PatchSize    EQU    3072                    ; size of our patch
  24.  
  25.  
  26.  
  27.  
  28. ;
  29. ;                P a t c h   I n s t a l l a t i o n   C o d e
  30. ;
  31.  
  32. SFPlace        FUNC    EXPORT
  33.  
  34. Entry
  35.  
  36.     LEA        trapdoor, A0                ; put instr code @ end of patch
  37.     MOVE.W    #$4EF9, (A0)                 ; 68000 code
  38.  
  39.     ; FUNCTION GetTrapAddress (trapNum: integer): longint;
  40.     ; trapNum => D0,   result => A0
  41.     MOVE.W    #ShowWind,D0                ; trap
  42.     _GetTrapAddress
  43.  
  44.     ; push it into the jmp Instruction
  45.     LEA        trapdoor+2,A1                ; put instr code here
  46.     MOVE.L    A0,(A1)                        ; install addr
  47.  
  48.     ; allocate space for patch in the system heap
  49.     ; FUNCTION NewPtr (size: longint): Ptr;
  50.     ; size => D0,   Ptr => A0
  51.     MOVE.L    #PatchSize,D0                ; patch size
  52.     _NewPtr SYS
  53.     MOVE.L    A0,-(SP)                    ; save ptr on stack
  54.  
  55.     ; copy patch to new block
  56.     ; PROCEDURE BlockMove (src, dest: ptr; size: longint);
  57.     ; src => A0,   dest => A1,  size => D0
  58.     MOVE.L    A0,A1                        ; dest of move
  59.     LEA        patchStart,A0                ; src of move
  60.     MOVE.L    #PatchSize,D0                ; patch size
  61.     _BlockMove
  62.  
  63.     ; Install Ptr to our patch in the dispatch table
  64.     ; PROCEDURE SetTrapAddress (trapAddr: longint; trapNum: integer);
  65.     ; trapAddr => A0,   trapNum => D0
  66.     MOVE.W    #ShowWind,D0                ; trap
  67.     MOVE.L    (SP)+,A0                    ; address of new patch
  68.     _SetTrapAddress
  69.  
  70.     RTS
  71.  
  72.  
  73. ;
  74. ;            E x e c u t a b l e   P a t c h   C o d e
  75. ;
  76. patchStart
  77.     MOVEM.L    A0-A1/D0-D2,-(SP)            ; save the registers
  78.     
  79.     ; Actual code of this patch
  80.  
  81.     MOVE.L    $0018 (A7),-(SP)
  82.     JSR        SpinFrame
  83.  
  84.     MOVEM.L    (SP)+, A0-A1/D0-D2            ; restore the registers
  85. trapdoor
  86.     DC.W    0,0,0                        ; will become JMP ABS.L
  87. svSysRef
  88.     DC.W    1
  89. svDirID
  90.     DC.L    2
  91. patchEnd
  92.  
  93.  
  94.     ENDFUNC
  95.  
  96.  
  97.     END
  98.